/*
 * openDesign.java
 *
 * Created on May 24, 2006, 10:02 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author Timoz
 */
import java.io.*;
import java.util.*;
import java.awt.*;

public class OpenDesign {
    static FileInputStream fis;
    static ObjectInputStream ois;
    
    /** Creates a new instance of openDesign */
    public OpenDesign() {
    }
    
    public static void openDesign (String formTitle)
    {
            String curDir = System.getProperty("user.dir");
            try
            {
                fis = new FileInputStream(curDir+"/Forms/"+MainWindow.host+"/"+MainWindow.selectedDatabase+"/"+formTitle);
                ois = new ObjectInputStream (fis);
                Dimension panelDimension=(Dimension)ois.readObject();
                Color panelBackgroundColor = (Color)ois.readObject();
                ArrayList<MyComponentContainer> componentList = (ArrayList<MyComponentContainer>)ois.readObject();
                String tableName = (String) ois.readObject();
                fis.close();
                ois.close();
                Toolkit kit = Toolkit.getDefaultToolkit();
                Dimension d=kit.getScreenSize();
                MyFrame myFrame = new MyFrame(d);
                myFrame.refreshComponents(panelDimension, panelBackgroundColor, componentList, tableName);
                myFrame.initializeNamesCount ();
                myFrame.setTitle(formTitle);
                myFrame.formatToolBar.refreshObjects();
                myFrame.formatToolBar.disableButtons();
                myFrame.setVisible(true);
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }
    }
    
}
